﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ACE.Wireless.PhoneBattery.BLL;
using ACE.Wireless.PhoneBattery.Common;
using ACE.Wireless.PhoneBattery.DataModel;

public partial class MainPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string headerInnerHtml = string.Empty;
            string jsFile = "<script language=\"javascript\" src=\"{0}\" type=\"text/javascript\"></script>";
            string cssFile = "<link rel=\"stylesheet\" href=\"{0}\" type=\"text/css\" media=\"print, projection, screen\" />";
            headerInnerHtml += string.Format(jsFile, ResolveUrl("~/css/jquery-1.2.3.min.js")) + Environment.NewLine;
            headerInnerHtml += string.Format(jsFile, ResolveUrl("~/css/thickbox.js")) + Environment.NewLine;
            headerInnerHtml += string.Format(jsFile, ResolveUrl("~/js/function.js")) + Environment.NewLine;
            headerInnerHtml += string.Format(cssFile, ResolveUrl("~/css/css.css")) + Environment.NewLine;
            headerInnerHtml += string.Format(cssFile, ResolveUrl("~/css/commom.css")) + Environment.NewLine;
            headerInnerHtml += string.Format(cssFile, ResolveUrl("~/css/thickbox.css")) + Environment.NewLine;
            Literal1.Text += headerInnerHtml;
        }
    }

    
    /// <summary>
    /// GetMemberPath
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    private string GetMemberPath(string path)
    {
        return "";
    }

    public bool IsHasPrivilege(int moduleId)
    {
        PageBase pageBase = new PageBase();

        //get user information from the session
        User user = pageBase.UserInfo;

        //if the user info is null, return false
        if (user == null) return false;

        if (user.Type == (int)Enumerations.UserType.Administrator)
            return true;
        else
        {
            switch (moduleId)
            {

                case (int)SystemModules.UserManagement:
                    return false;


                case (int)SystemModules.PhoneManagement:
                    return false;


                case (int)SystemModules.BatteryManagement:
                    return false;

                default:
                    return true;
            }  
        }

        return false;
    }

}
